# frozen_string_literal: true

# == Schema Information
#
# Table name: users
#
#  id             :integer          not null, primary key
#  name           :string
#  phone          :string(11)
#  open_id        :string
#  pets           :string           default([]), is an Array
#  pet_birth      :string
#  activated      :boolean          default(FALSE)
#  created_at     :datetime         not null
#  updated_at     :datetime         not null
#  nickname       :string
#  country        :string
#  province       :string
#  city           :string
#  headimgurl     :string
#  subscribe_time :string
#

class User < ApplicationRecord
  has_one :address
  has_many :coupons
  # accepts_nested_attributes_for :address
  validates :name, :phone, presence: true, on: :update

  before_update do
    self.activated = true
  end
end
